import Mock from 'mockjs';
import * as login from './moudel/login';
// fnCreated(login,true);
//设置拦截
function fnCreated(md,isOpen = true){
  if(isOpen){
    for(let key in md){
     let res = md[key]();
      Mock.mock(new RegExp(res.url),res.type,(opts) =>{
        opts['data'] = opts.body ? JSON.parse(opts.body) : null;
        delete opts.body;
        console.log('\n');
        console.log('%cmock拦截,请求：' , 'color:blue',opts);
        console.log('%cmock拦截,响应：' , 'color:blue',res.data);
        return res.data
      })
    }
  }
}
